package com.gcxy.controller;

import com.gcxy.core.PageVO;
import com.gcxy.core.R;
import com.gcxy.dto.role.AddRoleDTO;
import com.gcxy.dto.role.UpdateRoleDTO;
import com.gcxy.dto.role.RolePageDTO;
import com.gcxy.service.RoleService;
import com.gcxy.vo.role.RoleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 角色模块控制器
 *
 * @author pep7chiao
 * @date 2024/7/7
 */
@Api(tags = "角色管理")
@RestController
@RequestMapping("/role")
public class RoleController {
    @Resource
    private RoleService roleService;

    @ApiOperation("获取所有角色")
    @GetMapping("/getAllRoles")
    public R getAllRoles() {
        return R.Success(roleService.getAllRoles());
    }

    @ApiOperation("根据条件分页查询所有角色")
    @GetMapping("/getRolePageByCondition")
    public R<PageVO<RoleVO>> getRolePageByCondition(RolePageDTO rolePageDTO) {
        return R.Success(roleService.getRolePageByCondition(rolePageDTO));
    }

    @ApiOperation("更新角色")
    @PutMapping("/updateRole")
    public R<Void> updateRole(@Validated @RequestBody UpdateRoleDTO updateRoleDTO) {
        return roleService.updateRole(updateRoleDTO);
    }

    @ApiOperation("新增角色")
    @PostMapping("/insertRole")
    public R<Void> insertRole(@Validated @RequestBody AddRoleDTO addRoleDTO) {
        return roleService.insertRole(addRoleDTO);
    }

    @ApiOperation("删除角色")
    @DeleteMapping("/deleteRole/{id}")
    public R<Void> deleteRoleById(@PathVariable Integer id) {
        return roleService.deleteRoleById(id);
    }

//    @ApiOperation("获取当前登录用户可访问的页面")
//    @GetMapping("/admin/getAccessPath")
//    public List<String> getAccessPath() {
//        return roleService.getAccessPath();
//    }
}
